package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC1342 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int numberOfSteps(int num) {
            return num > 0 ? (int) (Math.log(num) / Math.log(2)) + bitCount(num) : num;
        }

        private int bitCount(int n) {
            n = n - ((n >>> 1) & 0x55555555);
            n = (n & 0x33333333) + ((n >>> 2) & 0x33333333);
            n = (n + (n >>> 4)) & 0x0F0F0F0F;
            return (n * 0x01010101) >>> 24;
        }
    }

    public void run() {
        Solution solution = new Solution();
        int[] arr = InputUtil.toIntegerArray("[1,2,3]");
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC1342 an = new LC1342();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
